/*
 * Copyright (c) 2008 Benoit Bouchez, Nicolas Giard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.noocodecommit.wicket.stuff.jquery.plugin.ui.droppable;

import org.apache.wicket.Component;

import com.noocodecommit.wicket.stuff.jquery.plugin.JQPluginOptions;

/**
 * JQDroppable Option set
 * 
 * @author Benoit Bouchez
 * 
 */
public class JQDroppableOptions extends JQPluginOptions implements Cloneable
{
	/** fit tolerance value */
	public static String TOLERANCE_FIT = "fit";
	/** intersect tolerance value */
	public static String TOLERANCE_INTERSECT = "intersect";
	/** pointer tolerance value */
	public static String TOLERANCE_POINTER = "pointer";
	/** touch tolerance value */
	public static String TOLERANCE_TOUCH = "touch";
	
	private String accept;
	private String activeClass;
	private boolean greedy;
	private String hoverClass;
	private String tolerance;

	private String activateScript = "";
	private String deactivateScript = "";
	private String acceptScript= "";
	private String overScript = "";
	private String outScript = "";
	private String dropScript = "";

	/**
	 * Constructor
	 */
	public JQDroppableOptions()
	{
		super();
		this.setDefaultHeader("droppable");
	}

	/**
	 * Gets the accept value
	 * 
	 * @return the accept value
	 */
	public String getAccept()
	{
		return accept;
	}

	/**
	 * Sets the accept option value
	 * 
	 * @param accept
	 *            droppable accept
	 */
	public void setAccept(String accept)
	{
		this.accept = accept;
		this.options.put("accept", "accept:'" + accept + "'");
	}

	/**
	 * Sets the accept option value
	 * 
	 * @param accept
	 *            droppable accept
	 */
	public void setAccept(Component accept)
	{
		this.accept = "#" + accept.getMarkupId();
		this.options.put("accept", "accept:'" + this.accept + "'");
	}

	/**
	 * Gets the active class value
	 * 
	 * @return the active class value
	 */
	public String getActiveClass()
	{
		return activeClass;
	}

	/**
	 * Sets the active class option value
	 * 
	 * @param activeClass
	 *            droppable active class
	 */
	public void setActiveClass(String activeClass)
	{
		this.activeClass = activeClass;
		this.options.put("activeClass", "activeClass:'" + activeClass + "'");
	}

	/**
	 * Gets the greedy value
	 * 
	 * @return the greedy value
	 */
	public boolean isGreedy()
	{
		return greedy;
	}

	/**
	 * Sets the greedy option value
	 * 
	 * @param greedy
	 *            droppable greedy
	 */
	public void setGreedy(boolean greedy)
	{
		this.greedy = greedy;
		this.options.put("greedy", "greedy:" + greedy);
	}

	/**
	 * Gets the hover class value
	 * 
	 * @return the hoverclass value
	 */
	public String getHoverClass()
	{
		return hoverClass;
	}

	/**
	 * Sets the hover class option value
	 * 
	 * @param hoverClass
	 *            droppable hover class
	 */
	public void setHoverClass(String hoverClass)
	{
		this.hoverClass = hoverClass;
		this.options.put("hoverClass", "hoverClass:'" + hoverClass + "'");
	}

	/**
	 * Gets the tolerance value
	 * 
	 * @return the tolerance value
	 */
	public String getTolerance()
	{
		return tolerance;
	}

	/**
	 * Sets the tolerance option value
	 * 
	 * @param tolerance
	 *            droppable tolerance
	 */
	public void setTolerance(String tolerance)
	{
		this.tolerance = tolerance;
		this.options.put("tolerance", "tolerance:'" + tolerance + "'");
	}

	/**
	 * Gets the activate script value
	 * 
	 * @return the activate function
	 */
	public String getActivateScript()
	{
		return activateScript;
	}

	/**
	 * Sets the activate function
	 * 
	 * @param activateScript
	 *            droppable activate function
	 */
	public void setActivateScript(String activateScript)
	{
		this.activateScript = activateScript;
		this.options.put("activate", "activate:function(ev, ui){" + activateScript + "}");
	}

	/**
	 * Gets the deactivate script value
	 * 
	 * @return the deactivate function
	 */
	public String getDeactivateScript()
	{
		return deactivateScript;
	}

	/**
	 * Sets the deactivate function
	 * 
	 * @param deactivateScript
	 *            droppable deactivate function
	 */
	public void setDeactivateScript(String deactivateScript)
	{
		this.deactivateScript = deactivateScript;
		this.options.put("deactivate", "deactivate:function(ev, ui){" + deactivateScript + "}");
	}

	/**
	 * Gets the over script value
	 * 
	 * @return the over function
	 */
	public String getOverScript()
	{
		return overScript;
	}

	/**
	 * Sets the over function
	 * 
	 * @param overScript
	 *            droppable over function
	 */
	public void setOverScript(String overScript)
	{
		this.overScript = overScript;
		this.options.put("over", "over:function(ev, ui){" + overScript + "}");
	}

	/**
	 * Gets the out script value
	 * 
	 * @return the out function
	 */
	public String getOutScript()
	{
		return outScript;
	}

	/**
	 * Sets the out function
	 * 
	 * @param outScript
	 *            droppable out function
	 */
	public void setOutScript(String outScript)
	{
		this.outScript = outScript;
		this.options.put("out", "out:function(ev, ui){" + outScript + "}");
	}

	/**
	 * Gets the drop script value
	 * 
	 * @return the drop function
	 */
	public String getDropScript()
	{
		return dropScript;
	}

	/**
	 * Sets the drop function
	 * 
	 * @param dropScript
	 *            droppable drop function
	 */
	public void setDropScript(String dropScript)
	{
		this.dropScript = dropScript;
		this.options.put("drop", "drop:function(ev, ui){" + dropScript + "}");
	}
	
	/**
	 * Gets the accept script value
	 * 
	 * @return the accept function
	 */
	public String getAcceptScript()
	{
		return acceptScript;
	}
	
	/**
	 * Sets the accept function
	 * 
	 * @param acceptScript
	 *            droppable accept function
	 */
	public void setAcceptScript(String acceptScript)
	{
		this.acceptScript = acceptScript;
		this.options.put("accept", "accept:function(draggable){" + acceptScript + "}");
	}
	
	@Override
	protected Object clone() throws CloneNotSupportedException
	{
		JQDroppableOptions clone = (JQDroppableOptions)super.clone();
		return clone;
	}
}
